package com.nuoniu.sibanyun.mapper.po;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.po.VPurchaseArrivalMain;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 * 采购到货单主表 Mapper 接口
 * </p>
 *
 * @author 小啊刚
 * @since 2020-11-19
 */
@Component
@Mapper
public interface VPurchaseArrivalMainMapper extends BaseMapper<VPurchaseArrivalMain> {

    @Select("select voucher_code from scp_receiving where company_id=#{companyId} and date_format(create_date, #{dateStr})=date_format(now(), #{dateStr}) AND data_source = #{dataSource} order by create_date desc limit 1")
    String getNewestCode(Integer companyId, String dateStr, String dataSource);

    @Select("select * from scp_receiving where company_id=#{companyId} and source_voucher_code=#{sourceVoucherCode}")
    List<VPurchaseArrivalMain> getBySourceCode(String sourceVoucherCode, Integer companyId);
}
